public class Main {


    public int romanToInt(String s) {
        char[] Luo = {'I','V','X','L','C','D','M'};

        int[] shu = {1,5,10,50,100,500,1000};
        char[] data = s.toCharArray();
        if(data[0]=='I'&&data[1]=='V'){
            return 4;
        }else if(data[0]=='I'&&data[1]=='X'){
            return 9;
        } else if (data[0]=='X'&&data[1]=='L') {
            return 40;
        } else if (data[0] == 'X' && data[1] == 'C') {
            return 90;
        }else if (data[0] == 'C' && data[1] == 'D') {
            return 400;
        }else if (data[0] == 'C' && data[1] == 'M') {
            return 900;
        }
        int sum=0;
        for (int i = 0; i < s.length(); i++) {
            for(int j=0;j<7;j++){
                if(data[i]==Luo[j]){
                    sum+=shu[j];
                }
            }
        }
        return sum;
    }
    public boolean isPalindrome(int x) {
        int y=0;
        int z=x;
        while(x>0){
            y=x%10+y*10;
            x=x/10;
        }
        if(y==z)
            return true;
        else
            return false;
    }


    public int removeDuplicates(int[] nums) {
        if(nums == null || nums.length == 0) return 0;
        int p = 0;
        int q = 1;
        while(q < nums.length){
            if(nums[p] != nums[q]){
                nums[p + 1] = nums[q];
                p++;
            }
            q++;
        }
        return p + 1;
    }



    public int[] twoSum(int[] nums, int target) {
        int[] array = new int[2];
        for (int i = 0; i < nums.length; i++) {
            for (int j = i + 1; j < nums.length; j++) {
                if (nums[i] + nums[j] == target) {
                    array[0] = i;
                    array[1] = j;
                }
            }
        }
        return array;
    }
}
